package DrugManagement

import (
	"MedicalTreatment/global"
	"MedicalTreatment/model"
	"github.com/gin-gonic/gin"
)

func DrugDelect(r *gin.Engine) {
	r.POST("/drugDel", func(context *gin.Context) {
		var drug model.Drug
		if err := context.ShouldBindJSON(&drug); err != nil {
			context.JSON(200, gin.H{
				"Msg": err,
			})
			return
		}
		if err := global.DB.Unscoped().Where("id = ?", drug.ID).Delete(&drug).Error; err != nil {
			context.JSON(200, gin.H{
				"Msg": err,
			})
		} else {
			context.JSON(200, gin.H{
				"Msg": "删除成功",
			})
		}
	})
}
